<?php
$uid = session('user_id');

include_once(ROOT_PATH . 'includes/lib_passport.php');
// 原密码
($old_password = _POST('old_passwd', '')) || abort(39);
// 新密码
$new_password = _POST('new_passwd', '');
// 确认密码
$confirm_passwd = _POST('confirm_passwd', '');

strlen($new_password) < 6 && abort(37);

$new_password === $confirm_passwd || abort(38);

edit_password($uid, $old_password, $new_password='') || abort(40);

return [];

// $old_password = isset($_POST['old_password']) ? trim($_POST['old_password']) : null;
// $new_password = isset($_POST['new_password']) ? trim($_POST['new_password']) : '';
// $user_id      = isset($_POST['uid'])  ? intval($_POST['uid']) : $user_id;
// $code         = isset($_POST['code']) ? trim($_POST['code'])  : '';
//
// strlen($new_password) < 6 && abort(37);
//
//
// $user_info = $user->get_profile_by_id($user_id); //论坛记录
//
// if (($user_info && (!empty($code) && md5($user_info['user_id'] . $_CFG['hash_code'] . $user_info['reg_time']) == $code)) || ($_SESSION['user_id']>0 && $_SESSION['user_id'] == $user_id && $user->check_user($_SESSION['user_name'], $old_password)))
// {
//
//     if ($user->edit_user(array('username'=> (empty($code) ? $_SESSION['user_name'] : $user_info['user_name']), 'old_password'=>$old_password, 'password'=>$new_password), empty($code) ? 0 : 1))
//     {
//         $sql="UPDATE ".$ecs->table('users'). "SET `ec_salt`='0' WHERE user_id= '".$user_id."'";
//         $db->query($sql);
//         $user->logout();
//         show_message($_LANG['edit_password_success'], $_LANG['relogin_lnk'], 'user.php?act=login', 'info');
//     }
//     else
//     {
//         show_message($_LANG['edit_password_failure'], $_LANG['back_page_up'], '', 'info');
//     }
// }
// else
// {
//     show_message($_LANG['edit_password_failure'], $_LANG['back_page_up'], '', 'info');
// }
